/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tallerfinal.view.distributions;

import tallerfinal.util.enums.DistributionsName;
import tallerfinal.view.distributions.factory.GeneratorViewFactory;

/**
 *
 * @author ricardo
 */
public class ConstantView extends GeneratorView {

    static {
        GeneratorViewFactory.getInstance().registerProduct(DistributionsName.CONSTANTE, ConstantView.class);
    }
    private Number a;

    /**
     * Creates new form ConstantView
     */
    public ConstantView() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        valField = new javax.swing.JFormattedTextField();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Editor Distribucion Constante"));
        setPreferredSize(new java.awt.Dimension(210, 50));
        setLayout(new java.awt.GridLayout(1, 2));

        jLabel1.setText("Valor : ");
        add(jLabel1);

        valField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        valField.setPreferredSize(new java.awt.Dimension(100, 20));
        valField.addAncestorListener( new RequestFocusListener() );
        add(valField);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JFormattedTextField valField;
    // End of variables declaration//GEN-END:variables

    @Override
    public Object[] getData() {
        a = (Number) valField.getValue();
        return new Object[]{a};
    }

    @Override
    public String tosString() {
        return "Distribucion Constante valor = " + a.toString();
    }
}
